<?php 

if (isset($_POST['ajax']) && isset($_POST['get']) && trim($_POST['get']) == "newguess") {
  exit;
  exit;
}



$write = "[".date("d.m.Y, H:i:s", time())."] ";
$fp = fopen("/srv/www.linuxcounter.net/logs/ajax_log", "a");
foreach($_POST AS $key => $val) {
  $write .= "$key:$val \t ";
}
fwrite($fp, $write."\n");
fclose($fp);



include ('./_config.inc.php');
$out = "";





if (isset($_POST['ajax']) && isset($_POST['action']) && trim($_POST['domComplete']) != "") {
	if (
		(float)$_POST['domainLookupEnd'] >= 0.010 && 
		(float)$_POST['domainLookupEnd'] <= 59.99 && 
		(float)$_POST['requestStart'] >= 0.010 && 
		(float)$_POST['requestStart'] <= 59.99 && 
		(float)$_POST['responseStart'] >= 0.010 && 
		(float)$_POST['responseStart'] <= 59.99 && 
		(float)$_POST['responseEnd'] >= 0.010 && 
		(float)$_POST['responseEnd'] <= 59.99 && 
		(float)$_POST['domComplete'] >= 0.010 && 
		(float)$_POST['domComplete'] <= 59.99
	) {
		$db->query("INSERT INTO stats_loadtime SET 
					url='" . mysql_real_escape_string(trim($_POST['url'])) . "', 
					countrycode='" . mysql_real_escape_string(strtoupper(trim($_POST['countrycode']))) . "', 
					country='" . mysql_real_escape_string(trim($_POST['country'])) . "', 
					region='" . mysql_real_escape_string(trim($_POST['region'])) . "',
					city='" . mysql_real_escape_string(trim($_POST['city'])) . "', 
					domComplete='" . mysql_real_escape_string((float)trim($_POST['domComplete'])) . "',
					responseEnd='" . mysql_real_escape_string((float)trim($_POST['responseEnd'])) . "',
					responseStart='" . mysql_real_escape_string((float)trim($_POST['responseStart'])) . "',
					requestStart='" . mysql_real_escape_string((float)trim($_POST['requestStart'])) . "',
					domainLookupEnd='" . mysql_real_escape_string((float)trim($_POST['domainLookupEnd'])) . "'
				");
	}
}


// CPU Autocomplete field
if (!isset($_POST['action']) && (isset($_POST['q']) && strtolower($_POST['q']) != "")) {
  $q = strtolower(stripslashes($_POST['q']));
  $sel = "SELECT * FROM `processors` ORDER BY `name` ASC, `herz` DESC";
  $bps = $db->getAll_assoc($sel);
  for ($a=0; $a<count($bps); $a++) {
    $id = $bps[$a]['f_key'];
    $name = $bps[$a]['name'];
    if (trim($bps[$a]['name']) != "")
      $herz = " @ ".$bps[$a]['herz'];
    else
      $herz = "";
    if (strpos(strtolower($name."".$herz), $q) !== false) {
      echo "".$name."".$herz."\n";
    }
  }
}




if (isset($_POST['ajax']) && isset($_POST['get']) && trim($_POST['get']) == "personal form") {
  $select = "SELECT *, UNIX_TIMESTAMP(f_ctime), UNIX_TIMESTAMP(f_mtime) FROM `users` WHERE `f_key`='".lico_ESC($_SESSION['userid'])."'";
  $seluser = $db->unbuffered_query_first($select);
  if (isset($seluser[0]) && intval($seluser[0]) >= 1) {
    //  f_key 	f_raw 	f_clean 	f_ctime 	f_mtime 	email 	login 	state 	privacy 	credentials 	logintime 	emailtime 	lang
    $f_key = intval($seluser[0]);
    $myregtime = date("Y/m/d, h:ia", intval($seluser[13]));
    $mylastchangetime = date("Y/m/d, h:ia", intval($seluser[14]));
    $myemail = trim($seluser[5]);
    $myoldcounternum = intval($seluser[13]);
  }
  $select = "SELECT *, UNIX_TIMESTAMP(f_ctime), UNIX_TIMESTAMP(f_mtime) FROM `persons` WHERE `f_key`='".lico_ESC($_SESSION['userid'])."'";
  $seluser = $db->unbuffered_query_first($select);
  if (isset($seluser[0]) && intval($seluser[0]) >= 1) {
    //  f_key 	f_raw 	f_clean 	f_ctime 	f_mtime 	name 	placeid 	placesource 	city 	state 	country 	email 	homepage 	ident 	may_publish 	method 	started 	usage
    $myname = trim($seluser[5]);
    $placeid = trim($seluser[6]);
    $placesource = trim($seluser[7]);
    $mycity = trim($seluser[8]);
    $mystate = trim($seluser[9]);
    $mycountry = trim($seluser[10]);
    $myhomepage = trim($seluser[12]);
  }
  $out .= "     <form name=\"setprofile\" action=\"/profile.html\" method=\"post\">\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myname').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myname]\" value=\"".html_entity_decode(trim($myname))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myemail').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myemail]\" value=\"".trim($myemail)."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'myhomepage').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[myhomepage]\" value=\"".trim($myhomepage)."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mycity').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[mycity]\" value=\"".html_entity_decode(trim($mycity))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mystate').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[mystate]\" value=\"".html_entity_decode(trim($mystate))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mycountry').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[mycountry]\" size=\"3\" maxlength=\"2\" value=\"".html_entity_decode(trim($mycountry))."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formsubmit formitem\">\n";
  $out .= "         <input type=\"hidden\" name=\"lico[action]\" value=\"setprofile\"/>\n";
  $out .= "         <span class=\"formsubmit-button\"><input type=\"submit\" name=\"lico[submit]\" value=\"".lico_lang('profile', 'save.data')."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "     </form>\n";
  echo $out;
}


else if (isset($_POST['ajax']) && isset($_POST['get']) && trim($_POST['get']) == "change passwd form") {
  $out .= "     <form name=\"changepasswd\" action=\"/profile.html\" method=\"post\">\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'old.password').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"password\" name=\"lico[oldpasswd]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'first.new.password').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"password\" name=\"lico[firstpasswd]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'second.new.password').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"password\" name=\"lico[secondpasswd]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formsubmit formitem\">\n";
  $out .= "         <input type=\"hidden\" name=\"lico[action]\" value=\"changepasswd\"/>\n";
  $out .= "         <span class=\"formsubmit-button\"><input type=\"submit\" name=\"lico[submit]\" value=\"".lico_lang('profile', 'save.new.password')."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "     </form>\n";
  echo $out;
}


else if (isset($_POST['ajax']) && isset($_POST['get']) && trim($_POST['get']) == "add machine form") {
  $out .= "     <form name=\"addmachine\" action=\"/profile.html\" method=\"post\">\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'name').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[name]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'country').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[country]\" size=\"3\" maxlength=\"2\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'purpose').":</label>\n";
  $out .= "         <span class=\"forminput checkpurpose\">\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'workstation')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"workstation\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'www.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"www.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'ftp.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"ftp.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'mail.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"mail.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'dns.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"dns.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'file.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"file.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'database.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"database.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'router')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"router\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'firewall')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"firewall\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'toy')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"toy\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'learning')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"learning\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'programming')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"programming\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'game.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"game.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'media.center')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"media.center\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'other.server')."</label>";
  $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"other.server\"/>\n";
  $out .= "           </div>\n";
  $out .= "           <div class=\"checkbox\">\n";
  $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'other.purpose')."</label>";
  $out .= "             <input class=\"formcheckalternative\" name=\"lico[alternatepurpose]\" size=\"55\" maxlength=\"40\"/>\n";
  $out .= "           </div>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'sysclass').":</label>\n";
  $out .= "         <span class=\"forminput\">\n";
  $out .= "           <select name=\"lico[sysclass]\">\n";
  $out .= "             <option value=\"\">-- ".lico_lang('general', 'not.specified')." --</option>\n";
  $out .= "             <option value=\"smartphone\">".lico_lang('general', 'smartphone')."</option>\n";
  $out .= "             <option value=\"handheld\">".lico_lang('general', 'handheld')."</option>\n";
  $out .= "             <option value=\"laptop\">".lico_lang('general', 'laptop')."</option>\n";
  $out .= "             <option value=\"workstation\">".lico_lang('general', 'workstation')."</option>\n";
  $out .= "             <option value=\"server\">".lico_lang('general', 'server')."</option>\n";
  $out .= "             <option value=\"embedded\">".lico_lang('general', 'embedded')." system</option>\n";
  $out .= "             <option value=\"other\">".lico_lang('general', 'other')."</option>\n";
  $out .= "           </select>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'cpu').":</label>\n";
  $out .= "         <span class=\"forminput\"><input id=\"cpuinput\" type=\"text\" name=\"lico[cpu]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'cpunum').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[cpunum]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'memory').":</label>\n";
  $out .= "         <span class=\"forminput\"><input id=\"memoryinput\" type=\"text\" name=\"lico[memory]\" value=\"4000\"/> MBytes</span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'disk').":</label>\n";
  $out .= "         <span class=\"forminput\"><input id=\"diskinput\" type=\"text\" name=\"lico[disk]\" value=\"1000\"/> MBytes</span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'network').":</label>\n";
  $out .= "         <span class=\"forminput\">\n";
  $out .= "           <select name=\"lico[network]\">\n";
  $out .= "             <option value=\"none\" selected=\"selected\">".lico_lang('general', 'none')."</option>\n";
  $out .= "             <option value=\"ethernet\">".lico_lang('general', 'ethernet')."</option>\n";
  $out .= "             <option value=\"ppp\">".lico_lang('general', 'ppp')."</option>\n";
  $out .= "             <option value=\"slip\">".lico_lang('general', 'slip')."</option>\n";
  $out .= "             <option value=\"ax.25\">".lico_lang('general', 'ax.25')."</option>\n";
  $out .= "             <option value=\"isdn\">".lico_lang('general', 'isdn')."</option>\n";
  $out .= "             <option value=\"token\">".lico_lang('general', 'token')."</option>\n";
  $out .= "             <option value=\"uucp\">".lico_lang('general', 'uucp')."</option>\n";
  $out .= "             <option value=\"wireless\">".lico_lang('general', 'wireless')."</option>\n";
  $out .= "             <option value=\"atm\">".lico_lang('general', 'atm')."</option>\n";
  $out .= "             <option value=\"adsl\">".lico_lang('general', 'adsl')."</option>\n";
  $out .= "             <option value=\"dsl\">".lico_lang('general', 'dsl')."</option>\n";
  $out .= "             <option value=\"sdsl\">".lico_lang('general', 'sdsl')."</option>\n";
  $out .= "             <option value=\"other\">".lico_lang('general', 'other')."</option>\n";
  $out .= "           </select>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'distribution').":</label>\n";
  $out .= "         <span class=\"forminput\">\n";
  $out .= "           <select name=\"lico[distribution]\">\n";
  $out .= "             <option value=\"unknown\">".lico_lang('general', 'unknown')."</option>\n";
  $out .= "             <option value=\"Red Hat\">Red Hat</option>\n";
  $out .= "             <option value=\"Fedora\">Fedora</option>\n";
  $out .= "             <option value=\"Mandrake\">Mandrake (before Mandriva)</option>\n";
  $out .= "             <option value=\"Mandriva\">Mandriva</option>\n";
  $out .= "             <option value=\"Debian\">Debian</option>\n";
  $out .= "             <option value=\"Slackware\">Slackware</option>\n";
  $out .= "             <option value=\"S.u.S.E\">S.u.S.E</option>\n";
  $out .= "             <option value=\"Linspire\">Linspire</option>\n";
  $out .= "             <option value=\"Gentoo\">Gentoo</option>\n";
  $out .= "             <option value=\"Ubuntu\">Ubuntu</option>\n";
  $out .= "             <option value=\"Knoppix\">Knoppix</option>\n";
  $out .= "             <option value=\"Conectiva\">Conectiva (before Mandriva)</option>\n";
  $out .= "             <option value=\"Caldera\">Caldera</option>\n";
  $out .= "             <option value=\"PLD\">PLD</option>\n";
  $out .= "             <option value=\"Smoothwall\">Smoothwall</option>\n";
  $out .= "             <option value=\"LinuxPPC\">LinuxPPC</option>\n";
  $out .= "             <option value=\"SLS\">SLS</option>\n";
  $out .= "             <option value=\"Yggdrasil\">Yggdrasil</option>\n";
  $out .= "             <option value=\"DLD\">DLD</option>\n";
  $out .= "             <option value=\"MCC\">MCC</option>\n";
  $out .= "             <option value=\"Mepis\">Mepis</option>\n";
  $out .= "             <option value=\"MkLinux\">MkLinux</option>\n";
  $out .= "             <option value=\"Stampede\">Stampede</option>\n";
  $out .= "             <option value=\"RockLinux\">RockLinux</option>\n";
  $out .= "             <option value=\"DIY\">Do-it-yourself</option>\n";
  $out .= "             <option value=\"LFS\">LFS - Linux From Scratch</option>\n";
  $out .= "             <option value=\"Lindows\">Lindows (before Linspire)</option>\n";
  $out .= "             <option value=\"ALT Linux\">ALT Linux</option>\n";
  $out .= "             <option value=\"Arch Linux\">Arch Linux</option>\n";
  $out .= "             <option value=\"Aurora\">Aurora SPARC Linux</option>\n";
  $out .= "             <option value=\"LFTAG\">LFTAG - Linux For The Average Guy</option>\n";
  $out .= "             <option value=\"other\">".lico_lang('general', 'other')."</option>\n";
  $out .= "           </select>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'distribution.version').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[distversion]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mailer').":</label>\n";
  $out .= "         <span class=\"forminput\">\n";
  $out .= "           <select name=\"lico[mailer]\">\n";
  $out .= "             <option value=\"none\" selected=\"selected\">".lico_lang('general', 'none')."</option>\n";
  $out .= "             <option value=\"unknown\">".lico_lang('general', 'unknown')."</option>\n";
  $out .= "             <option value=\"Sendmail\">Sendmail</option>\n";
  $out .= "             <option value=\"Smail\">Smail</option>\n";
  $out .= "             <option value=\"Qmail\">Qmail</option>\n";
  $out .= "             <option value=\"Exim\">Exim</option>\n";
  $out .= "             <option value=\"Postfix\">Postfix</option>\n";
  $out .= "             <option value=\"other\">".lico_lang('general', 'other')."</option>\n";
  $out .= "           </select>\n";
  $out .= "         </span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem odd\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'users').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[users]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formitem even\">\n";
  $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'accounts').":</label>\n";
  $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[accounts]\" value=\"\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "       <div class=\"formsubmit formitem\">\n";
  $out .= "         <input type=\"hidden\" name=\"lico[action]\" value=\"addmachine\"/>\n";
  $out .= "         <span class=\"formsubmit-button\"><input type=\"submit\" name=\"lico[submit]\" value=\"".lico_lang('profile', 'save.machine')."\"/></span>\n";
  $out .= "       </div>\n";
  $out .= "     </form>\n";
  $out .= "     <script type=\"text/javascript\"> \$('#cpuinput').autocomplete(\"/ajax.php\"); </script>\n";
  echo $out;
}



else if (isset($_POST['ajax']) && isset($_POST['get']) && isset($_POST['machineid']) && trim($_POST['get']) == "edit machine form" && intval($_POST['machineid']) >= 1) {
  
  
  $select = "SELECT *, UNIX_TIMESTAMP(f_ctime) AS ctime, UNIX_TIMESTAMP(f_mtime) AS mtime FROM `machines` WHERE `f_key`='".lico_ESC($_POST['machineid'])."' AND `owner`='".lico_ESC($_SESSION['userid'])."'";
	$ret = $db->getAll_assoc($select);
	if (count($ret) <= 0) {
  } else {
		$id = intval($ret[0]['f_key']);
    $ctime = date("Y/m/d, h:ia", intval($ret[0]['ctime']));
    $mtime = date("Y/m/d, h:ia", intval($ret[0]['mtime']));
    $name = trim($ret[0]['name']);
    $select = "SELECT * FROM `processors` WHERE `f_key`='".lico_ESC($ret[0]['cpu'])."'";
    $selcpu = $db->unbuffered_query_first($select);
    $cpu = trim($selcpu[1]);
    if (trim($selcpu[2]) != "")
      $cpu .= " @ ".trim($selcpu[2]);
    $cpunum = intval($ret[0]['cpunum']);
    $accounts = intval($ret[0]['accounts']);
    $country = trim($ret[0]['country']);
    $disk = intval($ret[0]['disk']);
    $distribution = trim($ret[0]['distribution']);
    $distversion = trim($ret[0]['distversion']);
    $mailer = trim($ret[0]['mailer']);
    $memory = intval($ret[0]['memory']);
    $network = trim($ret[0]['network']);
    $purpose = trim($ret[0]['purpose']);
    $source = trim($ret[0]['source']);
    $users = intval($ret[0]['users']);
    $sysclass = trim($ret[0]['sysclass']);
    if (preg_match("`,`", $purpose)) {
      $purpose = explode(",", $purpose);
    } else {
      $purpose = array($purpose);
    }
    $porposealternative = "";
    $purposes = array('workstation', 'www.server', 'ftp.server', 'mail.server', 'dns.server', 'file.server', 'database.server', 'router', 'firewall', 'toy', 'learning', 'programming', 'game.server', 'media.center', 'other.server');
    if (!in_array($purpose[count($purpose)-1], $purposes))
      $porposealternative = $purpose[count($purpose)-1];
    $out .= "     <form name=\"editmachine\" action=\"/profile.html\" method=\"post\">\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'name').":</label>\n";
    $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[name]\" value=\"".$name."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem odd\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'country').":</label>\n";
    $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[country]\" size=\"3\" maxlength=\"2\" value=\"".$country."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'purpose').":</label>\n";
    $out .= "         <span class=\"forminput checkpurpose\">\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'workstation')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"workstation\"".(in_array('workstation', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'www.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"www.server\"".(in_array('www.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'ftp.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"ftp.server\"".(in_array('ftp.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'mail.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"mail.server\"".(in_array('mail.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'dns.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"dns.server\"".(in_array('dns.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'file.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"file.server\"".(in_array('file.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'database.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"database.server\"".(in_array('database.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'router')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"router\"".(in_array('router', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'firewall')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"firewall\"".(in_array('firewall', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'toy')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"toy\"".(in_array('toy', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'learning')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"learning\"".(in_array('learning', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'programming')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"programming\"".(in_array('programming', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'game.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"game.server\"".(in_array('game.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'media.center')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"media.center\"".(in_array('media.center', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'other.server')."</label>";
    $out .= "             <input class=\"formcheckboxes\" name=\"lico[purpose][]\" type=checkbox value=\"other.server\"".(in_array('other.server', $purpose)?" checked=\"checked\"":"")."/>\n";
    $out .= "           </div>\n";
    $out .= "           <div class=\"checkbox\">\n";
    $out .= "             <label class=\"checkboxlabel\">".lico_lang('general', 'other.purpose')."</label>";
    $out .= "             <input class=\"formcheckalternative\" name=\"lico[alternatepurpose]\" size=\"55\" maxlength=\"40\" value=\"".$porposealternative."\"/>\n";
    $out .= "           </div>\n";
    $out .= "         </span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem odd\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'sysclass').":</label>\n";
    $out .= "         <span class=\"forminput\">\n";
    $out .= "           <select name=\"lico[sysclass]\">\n";
    $out .= "             <option value=\"\"".($sysclass==""?" selected=\"selected\"":"").">-- ".lico_lang('general', 'not.specified')." --</option>\n";
    $out .= "             <option value=\"smartphone\"".($sysclass=="smartphone"?" selected=\"selected\"":"").">".lico_lang('general', 'smartphone')."</option>\n";
    $out .= "             <option value=\"handheld\"".($sysclass=="handheld"?" selected=\"selected\"":"").">".lico_lang('general', 'handheld')."</option>\n";
    $out .= "             <option value=\"laptop\"".($sysclass=="laptop"?" selected=\"selected\"":"").">".lico_lang('general', 'laptop')."</option>\n";
    $out .= "             <option value=\"workstation\"".($sysclass=="workstation"?" selected=\"selected\"":"").">".lico_lang('general', 'workstation')."</option>\n";
    $out .= "             <option value=\"server\"".($sysclass=="server"?" selected=\"selected\"":"").">".lico_lang('general', 'server')."</option>\n";
    $out .= "             <option value=\"embedded\"".($sysclass=="embedded"?" selected=\"selected\"":"").">".lico_lang('general', 'embedded')." system</option>\n";
    $out .= "             <option value=\"other\"".($sysclass=="other"?" selected=\"selected\"":"").">".lico_lang('general', 'other')."</option>\n";
    $out .= "           </select>\n";
    $out .= "         </span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'cpu').":</label>\n";
    $out .= "         <span class=\"forminput\"><input id=\"cpuinput\" type=\"text\" name=\"lico[cpu]\" value=\"".$cpu."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'cpunum').":</label>\n";
    $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[cpunum]\" value=\"".$cpunum."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem odd\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'memory').":</label>\n";
    $out .= "         <span class=\"forminput\"><input id=\"memoryinput\" type=\"text\" name=\"lico[memory]\" value=\"".$memory."\"/> MBytes</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'disk').":</label>\n";
    $out .= "         <span class=\"forminput\"><input id=\"diskinput\" type=\"text\" name=\"lico[disk]\" value=\"".$disk."\"/> MBytes</span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem odd\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'network').":</label>\n";
    $out .= "         <span class=\"forminput\">\n";
    $out .= "           <select name=\"lico[network]\">\n";
    $out .= "             <option value=\"none\"".($network=="none"?" selected=\"selected\"":"").">".lico_lang('general', 'none')."</option>\n";
    $out .= "             <option value=\"ethernet\"".($network=="ethernet"?" selected=\"selected\"":"").">".lico_lang('general', 'ethernet')."</option>\n";
    $out .= "             <option value=\"ppp\"".($network=="ppp"?" selected=\"selected\"":"").">".lico_lang('general', 'ppp')."</option>\n";
    $out .= "             <option value=\"slip\"".($network=="slip"?" selected=\"selected\"":"").">".lico_lang('general', 'slip')."</option>\n";
    $out .= "             <option value=\"ax.25\"".($network=="ax25"?" selected=\"selected\"":"").">".lico_lang('general', 'ax.25')."</option>\n";
    $out .= "             <option value=\"isdn\"".($network=="isdn"?" selected=\"selected\"":"").">".lico_lang('general', 'isdn')."</option>\n";
    $out .= "             <option value=\"token\"".($network=="tokenring"?" selected=\"selected\"":"").">".lico_lang('general', 'token')."</option>\n";
    $out .= "             <option value=\"uucp\"".($network=="uucp"?" selected=\"selected\"":"").">".lico_lang('general', 'uucp')."</option>\n";
    $out .= "             <option value=\"wireless\"".($network=="wireless"?" selected=\"selected\"":"").">".lico_lang('general', 'wireless')."</option>\n";
    $out .= "             <option value=\"atm\"".($network=="atm"?" selected=\"selected\"":"").">".lico_lang('general', 'atm')."</option>\n";
    $out .= "             <option value=\"adsl\"".($network=="adsl"?" selected=\"selected\"":"").">".lico_lang('general', 'adsl')."</option>\n";
    $out .= "             <option value=\"dsl\"".($network=="dsl"?" selected=\"selected\"":"").">".lico_lang('general', 'dsl')."</option>\n";
    $out .= "             <option value=\"sdsl\"".($network=="sdsl"?" selected=\"selected\"":"").">".lico_lang('general', 'sdsl')."</option>\n";
    $out .= "             <option value=\"other\"".($network=="other"?" selected=\"selected\"":"").">".lico_lang('general', 'other')."</option>\n";
    $out .= "           </select>\n";
    $out .= "         </span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'distribution').":</label>\n";
    $out .= "         <span class=\"forminput\">\n";
    $out .= "           <select name=\"lico[distribution]\">\n";
    $out .= "             <option value=\"unknown\"".($distribution=="unknown"?" selected=\"selected\"":"").">".lico_lang('general', 'unknown')."</option>\n";
    $out .= "             <option value=\"Red Hat\"".($distribution=="Red Hat"?" selected=\"selected\"":"").">Red Hat</option>\n";
    $out .= "             <option value=\"Fedora\"".($distribution=="Fedora"?" selected=\"selected\"":"").">Fedora</option>\n";
    $out .= "             <option value=\"Mandrake\"".($distribution=="Mandrake"?" selected=\"selected\"":"").">Mandrake (before Mandriva)</option>\n";
    $out .= "             <option value=\"Mandriva\"".($distribution=="Mandriva"?" selected=\"selected\"":"").">Mandriva</option>\n";
    $out .= "             <option value=\"Debian\"".($distribution=="Debian"?" selected=\"selected\"":"").">Debian</option>\n";
    $out .= "             <option value=\"Slackware\"".($distribution=="Slackware"?" selected=\"selected\"":"").">Slackware</option>\n";
    $out .= "             <option value=\"S.u.S.E\"".($distribution=="S.u.S.E"?" selected=\"selected\"":"").">S.u.S.E</option>\n";
    $out .= "             <option value=\"Linspire\"".($distribution=="Linspire"?" selected=\"selected\"":"").">Linspire</option>\n";
    $out .= "             <option value=\"Gentoo\"".($distribution=="Gentoo"?" selected=\"selected\"":"").">Gentoo</option>\n";
    $out .= "             <option value=\"Ubuntu\"".($distribution=="Ubuntu"?" selected=\"selected\"":"").">Ubuntu</option>\n";
    $out .= "             <option value=\"Knoppix\"".($distribution=="Knoppix"?" selected=\"selected\"":"").">Knoppix</option>\n";
    $out .= "             <option value=\"Conectiva\"".($distribution=="Conectiva"?" selected=\"selected\"":"").">Conectiva (before Mandriva)</option>\n";
    $out .= "             <option value=\"Caldera\"".($distribution=="Caldera"?" selected=\"selected\"":"").">Caldera</option>\n";
    $out .= "             <option value=\"PLD\"".($distribution=="PLD"?" selected=\"selected\"":"").">PLD</option>\n";
    $out .= "             <option value=\"Smoothwall\"".($distribution=="Smoothwall"?" selected=\"selected\"":"").">Smoothwall</option>\n";
    $out .= "             <option value=\"LinuxPPC\"".($distribution=="LinuxPPC"?" selected=\"selected\"":"").">LinuxPPC</option>\n";
    $out .= "             <option value=\"SLS\"".($distribution=="SLS"?" selected=\"selected\"":"").">SLS</option>\n";
    $out .= "             <option value=\"Yggdrasil\"".($distribution=="Yggdrasil"?" selected=\"selected\"":"").">Yggdrasil</option>\n";
    $out .= "             <option value=\"DLD\"".($distribution=="DLD"?" selected=\"selected\"":"").">DLD</option>\n";
    $out .= "             <option value=\"MCC\"".($distribution=="MCC"?" selected=\"selected\"":"").">MCC</option>\n";
    $out .= "             <option value=\"Mepis\"".($distribution=="Mepis"?" selected=\"selected\"":"").">Mepis</option>\n";
    $out .= "             <option value=\"MkLinux\"".($distribution=="MkLinux"?" selected=\"selected\"":"").">MkLinux</option>\n";
    $out .= "             <option value=\"Stampede\"".($distribution=="Stampede"?" selected=\"selected\"":"").">Stampede</option>\n";
    $out .= "             <option value=\"RockLinux\"".($distribution=="RockLinux"?" selected=\"selected\"":"").">RockLinux</option>\n";
    $out .= "             <option value=\"DIY\"".($distribution=="DIY"?" selected=\"selected\"":"").">Do-it-yourself</option>\n";
    $out .= "             <option value=\"LFS\"".($distribution=="LFS"?" selected=\"selected\"":"").">LFS - Linux From Scratch</option>\n";
    $out .= "             <option value=\"Lindows\"".($distribution=="Lindows"?" selected=\"selected\"":"").">Lindows (before Linspire)</option>\n";
    $out .= "             <option value=\"ALT Linux\"".($distribution=="ALT Linux"?" selected=\"selected\"":"").">ALT Linux</option>\n";
    $out .= "             <option value=\"Arch Linux\"".($distribution=="Arch Linux"?" selected=\"selected\"":"").">Arch Linux</option>\n";
    $out .= "             <option value=\"Aurora\"".($distribution=="Aurora"?" selected=\"selected\"":"").">Aurora SPARC Linux</option>\n";
    $out .= "             <option value=\"LFTAG\"".($distribution=="LFTAG"?" selected=\"selected\"":"").">LFTAG - Linux For The Average Guy</option>\n";
    $out .= "             <option value=\"other\"".($distribution=="other"?" selected=\"selected\"":"").">Other".lico_lang('general', 'other')."</option>\n";
    $out .= "           </select>\n";
    $out .= "         </span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem odd\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'distribution.version').":</label>\n";
    $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[distversion]\" value=\"".$distversion."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'mailer').":</label>\n";
    $out .= "         <span class=\"forminput\">\n";
    $out .= "           <select name=\"lico[mailer]\">\n";
    $out .= "             <option value=\"none\"".($mailer=="none"?" selected=\"selected\"":"").">".lico_lang('general', 'none')."</option>\n";
    $out .= "             <option value=\"unknown\"".($mailer=="unknown"?" selected=\"selected\"":"").">".lico_lang('general', 'unknown')."</option>\n";
    $out .= "             <option value=\"Sendmail\"".($mailer=="Sendmail"?" selected=\"selected\"":"").">Sendmail</option>\n";
    $out .= "             <option value=\"Smail\"".($mailer=="Smail"?" selected=\"selected\"":"").">Smail</option>\n";
    $out .= "             <option value=\"Qmail\"".($mailer=="Qmail"?" selected=\"selected\"":"").">Qmail</option>\n";
    $out .= "             <option value=\"Exim\"".($mailer=="Exim"?" selected=\"selected\"":"").">Exim</option>\n";
    $out .= "             <option value=\"Postfix\"".($mailer=="Postfix"?" selected=\"selected\"":"").">Postfix</option>\n";
    $out .= "             <option value=\"other\"".($mailer=="other"?" selected=\"selected\"":"").">Other".lico_lang('general', 'other')."</option>\n";
    $out .= "           </select>\n";
    $out .= "         </span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem odd\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'users').":</label>\n";
    $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[users]\" value=\"".$users."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formitem even\">\n";
    $out .= "         <label class=\"formlabel\">".lico_lang('profile', 'accounts').":</label>\n";
    $out .= "         <span class=\"forminput\"><input type=\"text\" name=\"lico[accounts]\" value=\"".$accounts."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "       <div class=\"formsubmit formitem\">\n";
    $out .= "         <input type=\"hidden\" name=\"lico[action]\" value=\"editmachine\"/>\n";
    $out .= "         <input type=\"hidden\" name=\"lico[machineid]\" value=\"".intval($_POST['machineid'])."\"/>\n";
    $out .= "         <span class=\"formsubmit-button\"><input type=\"submit\" name=\"lico[submit]\" value=\"".lico_lang('profile', 'save.machine')."\"/></span>\n";
    $out .= "       </div>\n";
    $out .= "     </form>\n";
    $out .= "     <script type=\"text/javascript\"> \$('#cpuinput').autocomplete(\"/ajax.php\"); </script>\n";
    echo $out;
  }
}
else if (isset($_POST['ajax']) && isset($_POST['get']) && trim($_POST['get']) == "newguess") {
  
  $popcont = file($lico['temp_path']."population.db");
  $popstr = trim($popcont[0]);
  $iustr = trim($popcont[1]);
  $tmp = explode("|", $popstr);
  $pop = (float)$tmp[0];
  $date = $tmp[1];
  $rate = (float)$tmp[2];
  $tmp = explode("/", $date);
  $day = intval($tmp[1]);
  $mon = intval($tmp[0]);
  $year = intval($tmp[2]);
  $oldts = mktime(0,0,0, $mon, $day, $year);
  $aktts = time();
  $diff = $aktts - $oldts;
  $newhuman = $rate * $diff;
  $aktpop = $pop + $newhuman;
  $world_population                 =   round($aktpop);       // Number of all human beings on earth

  $tmp = explode("|", $iustr);
  $iupop = intval($tmp[0]);
  $iudate = $tmp[1];
  $iurate = (float)$tmp[2];
  $tmp = explode("/", $iudate);
  $day = intval($tmp[1]);
  $mon = intval($tmp[0]);
  $year = intval($tmp[2]);
  $oldts = mktime(0,0,0, $mon, $day, $year);
  $diff = $aktts - $oldts;
  $newiusers = $iurate * $diff;
  $aktiusers = $iupop + $newiusers;
  $world_internet_users             =   round($aktiusers);    // Number of internet users on earth

  $estimated_num_of_linux_users     =   (($world_internet_users / 100) * $lico['average_linux_users_in_percent']);
  $guestimate_users                 =   $estimated_num_of_linux_users;

  $guestimate_users_formatted = number_format($guestimate_users);
  echo $guestimate_users_formatted;
  
}


















?>